Skip to main content

SearchAndReplace

Finds and replaces the text.

Syntax

expression.SearchAndReplace(oProperties, oProperties.searchString, oProperties.replaceString, oProperties.matchCase);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
oPropertiesRequiredObjectThe properties to find and replace.
oProperties.searchStringRequiredstringSearch string.
oProperties.replaceStringRequiredstringReplacement string.
oProperties.matchCaseOptionalstringtrueCase sensitive or not.

Returns

This method doesn't return any data.

Example

This example shows how to make search and replace.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is the first sample text. The serial number of this sample text was replaced here.");
doc.SearchAndReplace({"searchString": "first", "replaceString": "second"});